import you_get
import sys
import requests
import json
import threading
def download(path,url):
    sys.argv = ['you-set', '-o', path, url]
    you_get.main()


def ExtractVedio():
    url='https://s.search.bilibili.com/cate/search?callback=jqueryCallback_bili_3430307910026633&main_ver=v3&search_type=video&view_type=hot_rank&order=click&copy_right=-1&cate_id=25&page=1&pagesize=20&jsonp=jsonp&time_from=20200416&time_to=20200423&_=1587626096128'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36',
        'cookie': 'bsource=seo_baidu; _uuid=2758A4BA-406E-8783-1BD2-FC0108240C1183536infoc; buvid3=0E78AC77-2E57-401F-93A5-2CD2CF7F9F9F53938infoc; sid=lnzvdbeb; DedeUserID=492692745; DedeUserID__ckMd5=06f74920ecfeccb1; SESSDATA=6ba1b87e%2C1603177175%2Ca3951*41; bili_jct=9dd29c737d0ccb99c49e6a94a516fb11'
    }
    reponse=requests.get(url,headers=headers).text
                       #数据转换成json数据
    json_data=json.loads(reponse[37:-1])
    # print(json_data)
    data=json_data["result"]
    # print(data)
    for i in data:
        arcurl_url=i['arcurl']
        # vedio_tag=i['tag']+'.mp4'
        # print(vedio_tag,arcurl_url)
        path = "D:\B站"
        download(path,arcurl_url)

if __name__=='__main__':
    # 视频的播放地址
    ExtractVedio()
    #download(path, url)